package Game;
import java.io.Serializable;

/**
 * GameDriver.java
 * 
 * This class represents the class that will control game play. This class is responsible for taking player turns, 
 * starting random events, and moving the player along the map
 * 
 * @author Ray DeCuir
 * @version 1.0
 */
public class GameDriver implements Serializable
{

	// the player's caravan object, see Caravan.java
	private Caravan playerCaravan;
	
	// the player's current Rations
	private Ration playerRation;
	
	// The player's current Pace
	private Pace playerPace;
	
	// Array list of items and location
	transient private static ItemList itemList;
	transient private static LocationList locationList;
	String message;
	
	/**
	 * 
	 * Constructor for the GameDriver Object, creates the caravan 
	 */
	public GameDriver()
	{
		initializeLists();
		playerCaravan = new Caravan(0);
		playerRation = Ration.getPlayerRation();
		playerPace = Pace.getPlayerPace();
	}
	
	public void initializeLists() {
		itemList = new ItemList();
		locationList = new LocationList();
		
	}
	
	public static ItemList getItemList() {
		return itemList;
	}
	
	public static LocationList getLocationList() {
		return locationList;
	}
	
	/**
	 * Main method that runs the Oregon Trail game
	 * 
	 * @param args Command line arguments
	 */
	public static void main(String[] args) 
	{
		GUIControl.start(new GameDriver());
		
		
	}
	
	/**
	 * 
	 * THis method calls smaller methods that must run each time the player takes a turn
	 */
	public void takeTurn()
	{
		playerCaravan.feedCharacters(playerRation);
		playerCaravan.travelUpdate(playerPace);
		RandomEvents r = new RandomEvents();
		playerCaravan = r.calculateEvents(playerCaravan, playerRation, playerPace);
		String message = r.getMessage();
		this.message = message;
		String lastEvent = r.getLastEvent();
		playerCaravan.increaseDay();
	}
	
	/*
	 * Getter for the caravan
	 */
	public Caravan getCaravan() {
		return playerCaravan;
	}
	/*
	 * Setter for the Caravan
	 * @param new Caravan object
	 */
	public void setCaravan(Caravan caravan) {
		playerCaravan = caravan;
	}
	/*
	 * Getter for the pace
	 */
	public Pace getPace() {
		return playerPace;
	}
	/*
	 * Setter for the pace
	 * @param new Pace object
	 */
	public void setPace(Pace pace) {
		playerPace = pace;
	}
	/*
	 * Getter for the Ration
	 */
	public Ration getRation() {
		return playerRation;
	}
	/*
	 * Setter for the pace
	 * @param new Caravan object
	 */
	public void setRation(Ration ration) {
		playerRation = ration;
	}
}
